package com.finance.quartz;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.serializers.JavaSerializer;
import com.finance.framework.qurtz.RunningStatus;
import com.finance.framework.qurtz.RunningStatusSource;
import org.objenesis.strategy.StdInstantiatorStrategy;
import org.quartz.Trigger;
import org.quartz.TriggerKey;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.management.ManagementFactory;
import java.util.List;

/**
 * Created by CBWL on 2017/6/5.
 */
@Component("runningStatusSource")
public class RunningStatusSourceImpl implements RunningStatusSource {
    @Autowired
    private RunningStatusDao runningStatusDao;

    @Override
    public RunningStatus get(TriggerKey triggerKey) {
        RunningStatus runningStatus = this.runningStatusDao.getByTrigger(triggerKey.getName(),triggerKey.getGroup());
        return runningStatus;
    }

    @Override
    public List<RunningStatus> listAll() {
        return this.runningStatusDao.listAll();
    }

    @Override
    public void save(TriggerKey triggerKey, byte[] runningStatus) {
        this.runningStatusDao.save(triggerKey.getName(),triggerKey.getGroup(),runningStatus);
    }

    @Override
    public void update(TriggerKey triggerKey, byte[]  runningStatus) {
        this.runningStatusDao.update(triggerKey.getName(),triggerKey.getGroup(),runningStatus);
    }




}
